<template>
	<view class="doctor-list card-page">
		<!-- <view class="doctor-list-title">
			{{deptName||''}}
		</view> -->
		<Search @search='onSearch' placeholder='请输入医生或科室名称搜索' />
		<view class="doctor-list-main">
			<view v-for="(item,index) in doctorList" :key="index" class="doctor-list-main-item">
				<view class="doctor-list-main-item-box flexR">
					<view class="img">
						<image v-if="item.headImg" :src="hostApi+item.headImg" mode="scaleToFill"></image>
						<image v-else src="/static/images/hospital/defaultDoctor.png" mode="scaleToFill"></image>
					</view>
					<view class="doctor-list-main-item-right" @click="toPage(item)">
						<view class="doctor-list-main-item-right-title flexR">
							<view class="title-left">
								<text class="name">{{item.name}}</text>
								<text class="tag">{{item.jobTitle}}</text>
							</view>
							<!-- 	<view class="right" @click.stop="toPagePath(item)">
								评价
							</view> -->
						</view>
						<view class="row">
							<text>{{item.deptName}}</text>
						</view>
						<view class="sc">
							擅长：{{item.specialty||'暂无信息'}}
						</view>
						<view class="num">
							<text v-if="item.serviceNum">接诊量：{{item.serviceNum}}</text>
							<text v-if="item.evaluateNum">评价数：{{item.evaluateNum}}</text>
						</view>
					</view>
				</view>
			</view>
			<u-empty v-if="doctorList.length===0&&load===false" text="该科室下无对应医生坐诊" mode="list"></u-empty>
		</view>
		<Load :load="load" />
	</view>
</template>

<script>
	import {
		selectByDeptOrDoctor
	} from '../../api/doctor'
	import Load from '@/components/Load/index.vue'
	import {
		mapGetters
	} from 'vuex'
	import Search from '@/components/Search/searchEmpty.vue'

	export default {
		components: {
			Load,
			Search
		},
		data() {
			return {
				load: false,
				deptCode: null,
				deptName: null,
				code: null,
				name: null,
				doctorList: [],
				code: '',
				name: '',
				campusInfo: {},
			}
		},
		computed: {
			...mapGetters(['hostApi', "userInfo", "currentHospitalInfo"])
		},
		onLoad(op) {

			this.initData()
		},
		methods: {
			toPage(item) {
				// 跳转到医生页面即显示医生介绍
				uni.setStorageSync("doctorCurrent", 2)
				uni.navigateTo({
					url: `/pages/Introduce/doctor?code=` + item.code
				})
			},
			initData() {
				let params = {
					name: this.name,
					campusCode: this.currentHospitalInfo.code,
					orderBy: 'sort'
				}
				selectByDeptOrDoctor(params).then(data => {
					this.load = false
					let res = data || []
					this.doctorList = res
				}).catch(e => {
					this.load = false
					this.doctorList = []
				})
			},
			onSearch(val) {
				this.name = val
				this.initData()
			},
			toPagePath(item) {
				uni.navigateTo({
					url: "/pages/Introduce/MedicalEvaluationTemplate?item=" + JSON.stringify(item)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.doctor-list {
		.doctor-list-title {
			height: 90rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 36rpx;
			color: $text-color-fff;
			background-color: $theme-color-light;
		}

		.doctor-list-main {
			height: calc(100vh - 90rpx);
			overflow: scroll;
			background-color: transparent;

			.doctor-list-main-item {
				background-color: transparent;
				padding-bottom: 24rpx;

				.doctor-list-main-item-box {
					background-color: $uni-bg-color;
					padding: 24rpx 24rpx;
					border-radius: 8upx;

					.img {
						width: 70px;
						height: 70px;
						// overflow: hidden;
						margin-right: 30rpx;

						>image {
							width: 70px;
							height: 70px;
							border-radius: 8upx;
						}
					}

					>.doctor-list-main-item-right {
						flex: 1;

						>view {
							margin-bottom: 10upx;
						}

						.doctor-list-main-item-right-title {
							height: 40rpx;
							line-height: 40rpx;
							font-size: 28rpx;
							color: #000000;
							justify-content: space-between;
							font-weight: bold;
							margin-bottom: 10rpx;

							>.title-left {
								.name {
									font-family: PingFang SC, PingFang SC;
									font-weight: 500;
									font-size: 32upx;
									color: rgba(0, 0, 0, 0.7);
								}

								.tag {
									// font-size: 24rpx;
									// font-weight: 100;
									// color: $text-color;
									// background-color: $tag-color;
									// height: 36rpx;
									// line-height: 36rpx;
									// padding: 7rpx 17rpx;
									// border-radius: 5rpx;
									// margin-left: 10rpx;

									font-family: PingFang SC, PingFang SC;
									font-weight: 400;
									font-size: 24upx;
									color: rgba(0, 0, 0, 0.4);
									margin-left: 16upx;
								}
							}

							.right {
								float: right;
								padding: 0 32upx;
								background-color: $theme-color;
								font-family: PingFang SC, PingFang SC;
								font-weight: 400;
								font-size: 24upx;
								color: #FFF;
								border-radius: 50upx;
								transform: translateY(-10upx);
							}
						}

						>.row {
							>text {
								// color: $theme-color-light;
								font-family: PingFang SC, PingFang SC;
								font-weight: 400;
								font-size: 24upx;
								color: rgba(0, 0, 0, 0.7);
							}
						}

						.sc {
							// height: 40px;
							// line-height: 20px;
							// font-size: 12px;
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							font-size: 20upx;
							overflow: hidden;
							text-overflow: ellipsis;
							display: -webkit-box; // 作为弹性伸缩盒子模型显示。
							-webkit-box-orient: vertical; // 设置伸缩盒子的子元素排列方式--从上到下垂直排列
							-webkit-line-clamp: 1; // 显示的行
						}

						.num {
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							font-size: 20upx;

							>text {
								&:nth-child(1) {
									color: #FFAA32;
								}

								&:nth-child(2) {
									color: #5DD2B1;
									margin-left: 20upx;
								}
							}

						}
					}
				}
			}
		}
	}
</style>